<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>『 知音培训信息管理平台』</title>
	<script type="text/javascript" src="__PUBLIC__/Resourse/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" charset="UTF-8" src="__PUBLIC__/Resourse/js/jquery.cookie.js"></script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Resourse/themes/default/easyui.css" id="easyuiTheme">
	<script type="text/javascript" charset="UTF-8" src="__PUBLIC__/Resourse/js/changeEasyuiTheme.js"></script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Resourse/themes/icon.css">
	<script type="text/javascript" src="__PUBLIC__/Resourse/js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/Resourse/js/common.js"></script>
	<script type="text/javascript" src="__PUBLIC__/Resourse/locale/easyui-lang-zh_CN.js"></script>
	<style type="text/css">
		body {
			margin:0px;
			padding:0px;
			width:100%;
			height:100%;
		}
		.formStyle{  
            margin:0;  
            padding:10px 10px 30px 5px;  
       }  
       .ftitle{  
            font-size:14px;  
            font-weight:bold;  
            padding:5px 0;  
            margin-bottom:10px;  
            border-bottom:1px solid #ccc;  
        }  
       .fitem{  
            margin-bottom:5px;  
       }  
        .fitem label{  
           display:inline-block;  
            width:80px;  
        }
        .formText {
        	width : 200px;
        }  
	</style>
	<script type="text/javascript">
		var flUrl ="";
		var itemUrl="";
		
		$(function() {		
			$("#searchDiv").hide();
			$(window).resize(function(){
				$('#dg').datagrid('resize');
			});
			//设置分页控件   
			/*
		    var p = $('#dg').datagrid('getPager');  
		    $(p).pagination({  
		        pageSize: 15,//每页显示的记录条数，默认为10   
		        pageList: [15,20,30],//可以设置每页记录条数的列表   
		        beforePageText: '第',//页数文本框前显示的汉字   
		        afterPageText: '页    共 {pages} 页',  
		        displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
		        /*onBeforeRefresh:function(){ 
		            $(this).pagination('loading'); 
		            alert('before refresh'); 
		            $(this).pagination('loaded'); 
		        }*/  
		    //});  
		    
		    /*
		    $('#KC_DW').combobox({
		    	onChange:function(){
		    		//var departText = $('#KC_DW').combobox('getText'); //获取文本值
		    		//alert(departText);
		    		
		    	}
		    });*/
		    
		    $('#dg').datagrid({
		        pageSize: 15,//每页显示的记录条数，默认为10   
		        pageList: [15,20,30],//可以设置每页记录条数的列表   
		        beforePageText: '第',//页数文本框前显示的汉字   
		        afterPageText: '页    共 {pages} 页',  
		        displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
		    	onDblClickRow: function(index,row){
			           //var row = $('#dg').datagrid('getSelected');  
			            if (row){  
			               $('#dlgCourse').dialog('open').dialog('setTitle','查看课程');  
			               $('#fmCourse').form('load',row);  
			               disableForm('fmCourse',true);
			               $('#saveBnt').hide();
			           }else{
			        	   $.messager.alert('消息','请选择一个数据项!','info');
			           }  
		    	}
		    });

		});
		
		$(document).ready(function(){	
			var skin = $.cookie('easyuiThemeName');
			if (skin != null && typeof skin != undefined) {
				changeThemeFun(skin);
			}
			//expandAll();		
		});
		
	      function newCourse(){  
	           $('#dlgCourse').dialog('open').dialog('setTitle','新建课程');  
	           $('#fmCourse').form('clear');  
	           disableForm('fmCourse',false);
	           $('#saveBnt').show();
	           itemUrl = '__URL__/add'; 
	       }  
	        
	       function editCourse(){  
	           var row = $('#dg').datagrid('getSelected');  
	            if (row){
	            	disableForm('fmCourse',false);
	            	$('#saveBnt').show();
	               	$('#dlgCourse').dialog('open').dialog('setTitle','编辑课程'); 
	               	debugger;
	               	//$('#fmCourse').form('load','__URL__/editBefore/id/'+row.Id);  
	               	$('#fmCourse').form('load',row);  
	               	itemUrl =  '__URL__/save/id/'+row.Id;  
	           }else{
	        	   	$.messager.alert('消息','请选择一个数据项!','info');
	           }  
	       }
	       
	      function saveCourse(){  
	           $('#fmCourse').form('submit',{  
	               	url: itemUrl,  
	                onSubmit: function(){  
	                	$('#KC_DWMC').val($('#KC_DW').combobox('getText'));
	                   return $(this).form('validate');  
	                },  
	                success: function(result){  
	                    var result = eval('('+result+')');  
	                    if (result.success){  
	                    	$.messager.alert('消息','操作成功!','info');
	                        $('#dlgCourse').dialog('close');      // close the dialog  		
	                        //reloadDataGrid();
	                        $('#dg').datagrid('reload');    // reload the user data  
	                    } else {  
	                        $.messager.show({  
		                           title: 'Error',  
		                           msg: result.errorMsg  
		                    });  
	                    }  
	                }  
	            });  
	      }
	      
		function doSearch(){
			$('#dg').datagrid('load',{
				XQ: $('#XQ').combobox('getValue'),
				KM: $('#KMBH').combobox('getValue'),
				KCMC: $('#BJMC').val()
			});
		}
	      
		function beforeSearch(){
			$("#searchDiv").toggle();
		}
		
	    function destroyCourse(){  
	           var rows = $('#dg').datagrid('getSelections');
	           var ids = '';
	           for(var i=0;i<rows.length;i++){
	        	   ids += rows[i].Id + ',';
	           }
	          ids = ids.substring(0, ids.length-1);//获取所有要删除的ID
	            if (rows.length >0){  
	               $.messager.confirm('Confirm','确定要删除选中的 ' + rows.length +' 个课程吗?',function(r){  
	                  if (r){  
	                     $.post('__URL__/del',{id:ids},function(result){  
	                           if (result.success){  
	                           	//reloadDataGrid();
	                           		$.messager.alert('消息','操作成功!','info');
	                             	$('#dg').datagrid('reload');    // reload the user data  
	                           } else {  
	                              $.messager.show({   // show error message  
	                                   title: 'Error',  
	                                   msg: result.errorMsg  
	                               });  
	                          }  
	                      },'json');  
	                   }  
	               });  
	           }else{
	           		$.messager.alert('消息','请选择一个数据项!','info');
	           }  
	     }  

	</script>
</head>
<body class="easyui-layout" style="border-width:50px;margin:0">
	<div id="mainPanle"  region="center"  border="false" >
		<table id="dg" class="easyui-datagrid" style="margin:0" 
							data-options="title:'课程信息列表',border:true,striped:true,nowrap:false,fit:true,autoRowHeight:false,rownumbers:true,pagination:true,singleSelect:false,
												loadMsg:'数据加载中请稍后……',  
												pageSize:10,url:'__URL__/getDisplayList',toolbar:'#tb' ">
			<thead>
				<tr>
					<th data-options="field:'checkbox',checkbox:true" id="checkedAll"></th>
					<th data-options="field:'Id',fitColumns: true,hidden:true">Id</th>
					<th data-options="field:'KC_XQ',fitColumns: true,hidden:true">所属校区</th>
					<th data-options="field:'KC_NJ',fitColumns: true,hidden:true">年级</th>
					<th data-options="field:'KC_KMBH',itColumns: true,hidden:true">科目</th>
					<th data-options="field:'XQ',fitColumns: true,align:'center',sortable:true">所属校区</th>
					<th data-options="field:'NJ',fitColumns: true,align:'center',sortable:true">年级</th>
					<th data-options="field:'KM',itColumns: true,align:'center',sortable:true">科目</th>
					<th data-options="field:'KC_BJMC',itColumns: true,align:'center',sortable:true">课程班级名称</th>
					<th data-options="field:'KC_ZRS',itColumns: true,align:'center'">总人数</th>
					<th data-options="field:'KC_YBRS',itColumns: true,align:'center',sortable:true">已报人数</th>
					<th data-options="field:'KC_KCFY',itColumns: true,align:'center',sortable:true">课程金额</th>
					<th data-options="field:'KC_ZK',itColumns: true,align:'center'">折扣</th>
					<th data-options="field:'KC_BZR',itColumns: true,hidden:true">班主任</th>
					<th data-options="field:'BZR',itColumns: true,align:'center'">班主任</th>
					<th data-options="field:'KC_LSBH',itColumns: true,hidden:true">授课老师</th>
					<th data-options="field:'TEACHER',itColumns: true,align:'center'">授课老师</th>
					<th data-options="field:'KC_CS',itColumns: true,align:'center'">课次数</th>
					<th data-options="field:'KC_SRQ',itColumns: true,align:'center'">上课时间</th>
					<th data-options="field:'KC_SWITCH',itColumns: true,align:'center'">开启状态</th>
					<th data-options="field:'status',itColumns: true,width:80,align:'center',formatter:function(value,rowData,rowIndex){ if(value == '1'){ return '活跃'} else { return '冻结'}}">数据状态</th>
					<th data-options="field:'KC_BZ',itColumns: true,align:'center'">备注</th>
				</tr>
			</thead>
		</table>
		<div id="tb" style="padding:5px;height:auto">
			<div style="margin-bottom:5px" >
			 	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newCourse()">添加课程</a>
				<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editCourse()">编辑课程</a> 
				<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyCourse()">删除课程</a>  
				<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="beforeSearch()">检索</a>  
			</div>
			<div id="searchDiv">
		    	<div>  
		        	校区: <input class="easyui-combobox" id="XQ" name="XQ" data-options="valueField:'ITEM_KEY',textField:'text',url:'__URL__/getDictList/flValue/XQ'">
		        	科目: <input class="easyui-combobox" id="KMBH" name="KMBH" data-options="valueField:'ITEM_KEY',textField:'text',url:'__URL__/getDictList/flValue/KM'">  
		        	班级名称:<input id="BJMC" name="BJMC" class="easyui-validatebox" >    
		        	<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="doSearch()">Search</a>  
		    	</div>  
			</div>
			<!--<div id="separator1"  style="float: left;" class="datagrid-btn-separator"></div> -->
		</div>
	</div>

    <div id="dlgCourse" class="easyui-dialog" style="width:650px;height:470px;padding:0px 0px 0px 0px"  closed="true" 
    		data-options="iconCls:'icon-save',resizable:false,modal:true" buttons="#dlgCourse-buttons">  
        <form id="fmCourse" class="formStyle"  method="post" novalidate>
        	<table cellspacing="10">
        		<tr>
        			<td>
			            <div class="fitem">  
			                <label>所属校区:</label> 
			                <input name="id"  type="hidden">
							<input class="easyui-combobox" id="KC_XQ" name="KC_XQ" data-options="valueField:'ITEM_KEY',textField:'text',url:'__URL__/getDictList/flValue/XQ'" required>
			            </div>    
			            <div class="fitem">  
			                <label>年级:</label>  
			               	<input class="easyui-combobox" id="KC_NJ" name="KC_NJ" data-options="valueField:'ITEM_KEY',textField:'text',url:'__URL__/getDictList/flValue/JDNJ'" required>
			            </div>
			            <div class="fitem">  
			                <label>科目:</label>  
			                <input class="easyui-combobox" id="KC_KMBH" name="KC_KMBH" data-options="valueField:'ITEM_KEY',textField:'text',url:'__URL__/getDictList/flValue/KM'" required>
			            </div>
			            <div class="fitem">  
			                <label>课程单位:</label>  
			                <input id="KC_DW"  name="KC_DW"  class="easyui-combobox" data-options="valueField:'ITEM_KEY',textField:'text',url:'__URL__/getDictList/flValue/KCDW'" required>
			                <input  id="KC_DWMC"  name="KC_DWMC"  type="hidden" >
			            </div>  
			            <div class="fitem">  
			                <label>班级名称:</label>  
			                <input id="KC_BJMC" name="KC_BJMC" class="easyui-validatebox"  required>  
			            </div>  
			            <div class="fitem">  
			                <label>班级人数:</label>  
			                <input id="KC_ZRS" name="KC_ZRS"  class="easyui-numberbox" required>
			            </div>
			            <div class="fitem">  
			                <label>已报人数:</label>  
			                <input id="KC_YBRS" name="KC_YBRS"  class="easyui-numberbox" value="0.0"  required>
			            </div>
			            <div class="fitem">  
			                <label>课次数:</label>  
			                <input id="KC_CS" name="KC_CS"  class="easyui-numberbox" required>
			            </div>
			             <div class="fitem">  
			                <label>备注:</label>  
			                <textarea id="KC_BZ" name="KC_BZ" style="height:60px;"></textarea>
			            </div> 
            		</td>
            	<td>
		            <div class="fitem">  
		                <label>课程费用:</label>  
		                <input id="KC_KCFY" name="KC_KCFY"  class="easyui-numberbox" value="0.00" data-options="precision:2,groupSeparator:',',decimalSeparator:'.',prefix:'￥'" required></input>
		            </div>
		            <div class="fitem">  
		                <label>课程折扣:</label>  
		                <input id="KC_ZK" name="KC_ZK"  class="easyui-numberbox" value="0" data-options="precision:1,groupSeparator:'.',decimalSeparator:'.'"></input>
		            </div>
		            <div class="fitem">  
		                <label>班主任:</label>  
		                <input id="KC_BZR" name="KC_BZR"  class="easyui-combobox" data-options="valueField:'id',textField:'text',url:'__URL__/getUserList/type/yg3'" required>
		            </div>
		            <div class="fitem">  
		                <label>代课老师:</label>  
		                <input id="KC_LSBH" name="KC_LSBH"  class="easyui-combobox" data-options="valueField:'id',textField:'text',url:'__URL__/getUserList/type/yg1'" required>
		            </div>
		            <div class="fitem">  
		                <label>开课日期:</label>  
		                <input id="KC_SRQ" name="KC_SRQ"  class="easyui-datebox"></input>
		            </div>
		            <div class="fitem">  
		                <label>星期:</label>  
		                <select class="easyui-combobox" id="KC_WEEK"  name="KC_WEEK" style="width:200px;">
							<option value="0">Sunday</option>
							<option value="1">Monday</option>
							<option value="2">Tuesday</option>
							<option value="3">Wednesday</option>
							<option value="4">Thursday</option>
							<option value="5">Friday</option>
							<option value="6">Saturday</option>
						</select>
		            </div>
		            <div class="fitem">  
		                <label>上课时间:</label>  
		                <input id="KC_STIME"  name="KC_STIME" class="easyui-timespinner" style="width:80px;">
		            </div>
		            <div class="fitem">  
		                <label>下课时间:</label>  
		                <input id="KC_ETIME"  name="KC_ETIME" class="easyui-timespinner" style="width:80px;">
		            </div>
		            <div class="fitem">  
		                <label>课程状态:</label>  
		                <INPUT type="radio" name="KC_SWITCH" checked="checked" value="1">开启
						<INPUT type="radio" name="KC_SWITCH" value="0">不开启
		           </div> 
		           <div class="fitem">  
		                <label>课程说明:</label>  
		                <textarea id="KC_SM" name="KC_SM" style="height:60px;"></textarea>
		            </div>      
            		</td>
            	</tr>
            </table>    
        </form>  
    </div>  
    <div id="dlgCourse-buttons">  
        <a id="saveBnt" href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveCourse()">保存</a>  
       	<a  id="cancelBnt"  href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlgCourse').dialog('close')">取消</a>  
    </div> 
</body>
</html>